// Copyright (C) 2016  Francisco Javier Parra <franparpe@openmailbox.org>

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

#ifndef XMPPLAR_CLIENT_H
#define XMPPLAR_CLIENT_H

#include<gtkmm.h>
#include "main-window.h"
#include<iostream>
#include <mutex>
#include "conversation_container.h"
#include <string.h>
#include <gloox/message.h>
#include <gloox/messagehandler.h>
#include <gloox/connectionlistener.h>
#include <gloox/client.h>

class MainWindow;

class XmpplarClient : gloox::MessageHandler, gloox::ConnectionListener,
                      public gloox::Client
{
private:
  MainWindow *m_caller;
  std::string m_message_cnt;
public:
  XmpplarClient(MainWindow* caller, gloox::JID& jid, std::string password);

  // Methods to manipulate the connection
  bool startConnection();

  virtual void handleMessage(const gloox::Message &stanza,
                             gloox::MessageSession* session = 0 );

  virtual void onConnect();
  virtual void onDisconnect(gloox::ConnectionError e);
  virtual bool onTLSConnect(const gloox::CertInfo & info);

  std::string getBody();
};

#endif
